package rollercoaster.railway;

import rollercoaster.commons.Vertex3D;
import rollercoaster.commons.interfaces.ICurve3D;

public class Segment implements ICurve3D {

	private Vertex3D start_point;
	private Vertex3D end_point;
	
	
	
	public Segment(Vertex3D start_point, Vertex3D end_point) {
		super();
		this.start_point = start_point;
		this.end_point = end_point;
	}
	
	public Vertex3D gamma(float t) {
		if(t<0)t=0;
		if(t>1)t=1;
		float x=start_point.getX()+t*(end_point.getX()-start_point.getX());
		float y=start_point.getY()+t*(end_point.getY()-start_point.getY());
		float z=start_point.getZ()+t*(end_point.getZ()-start_point.getZ());
		return new Vertex3D(x, y, z);
	}

	public Vertex3D dGammadt(float t) {
		float x=(end_point.getX()-start_point.getX());
		float y=(end_point.getY()-start_point.getY());
		float z=(end_point.getZ()-start_point.getZ());
		return new Vertex3D(x, y, z);
	}

	public float getStartPoint() {
		return 0;
	}

	public float getEndPoint() {
		return 1;
	}
	
	public Vertex3D getStart_point() {
		return start_point;
	}



	public void setStart_point(Vertex3D start_point) {
		this.start_point = start_point;
	}
	
	public Vertex3D getEnd_point() {
		return end_point;
	}

	public void setEnd_point(Vertex3D end_point) {
		this.end_point = end_point;
	}
	
}
